package com.site.dao;

import com.site.common.DbHelper;
import com.site.entity.CaseEntity;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class CaseDao extends DbHelper {
    public CaseDao() throws ClassNotFoundException, SQLException{

    }

    //得到所有的案例信息
    public List<CaseEntity> getAll() throws SQLException{
        ResultSet rs=query("select * from tbCaseAppreciation");
        List<CaseEntity> list=new ArrayList<CaseEntity>();
        while (rs.next()){
            list.add(getEntity(rs));
        }

        rs.close();
        close();
        return list;
    }

    private CaseEntity getEntity(ResultSet rs) throws SQLException{
        CaseEntity entity=new CaseEntity();
        entity.setId(rs.getString("id"));
        entity.setRemark(rs.getString("remark"));
        entity.setTitle(rs.getString("title"));
        entity.setBgImg(rs.getString("bgImg"));
        return entity;
    }
}
